package com.xuxin.queue.view;

import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.blankj.utilcode.util.StringUtils;
import com.lxj.xpopup.animator.PopupAnimator;
import com.lxj.xpopup.core.CenterPopupView;
import com.xuxin.queue.R;

/**
 * Created by xu_xin
 * Created on 2021/7/2 0002
 */
public class QueuePopup extends CenterPopupView {
    private TextView popup_queue_name;
    private String name;

    public QueuePopup(@NonNull Context context) {
        super(context);
    }

    public QueuePopup(@NonNull Context context, String name) {
        super(context);
        this.name = name;
    }

    public void setName(String name) {
        if (null != popup_queue_name) {
            popup_queue_name.setText(name);
        }
    }

    // 返回自定义弹窗的布局
    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_queue;
    }

    // 执行初始化操作，比如：findView，设置点击，或者任何你弹窗内的业务逻辑
    @Override
    protected void onCreate() {
        super.onCreate();
        popup_queue_name = findViewById(R.id.popup_queue_name);
        if (!StringUtils.isEmpty(name)) {
            popup_queue_name.setText(name);
        }
    }

    // 设置最大宽度，看需要而定，
    @Override
    protected int getMaxWidth() {
        return super.getMaxWidth();
    }

    // 设置最大高度，看需要而定
    @Override
    protected int getMaxHeight() {
        return super.getMaxHeight();
    }

    // 设置自定义动画器，看需要而定
    @Override
    protected PopupAnimator getPopupAnimator() {
        return super.getPopupAnimator();
    }

    /**
     * 弹窗的宽度，用来动态设定当前弹窗的宽度，受getMaxWidth()限制
     *
     * @return
     */
    protected int getPopupWidth() {
        return 0;
    }

    /**
     * 弹窗的高度，用来动态设定当前弹窗的高度，受getMaxHeight()限制
     *
     * @return
     */
    protected int getPopupHeight() {
        return 0;
    }
}